<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Crud Example with Spring Hibernate</title>
	
	<script type="text/javascript" src="<c:url value="/resources/scripts/jquery.js"/>"></script>
	<script type="text/javascript">
        $(document).ready(function() {
        	$("#btn-save").click(function(){
        		
        		var okToSubmit = true;
	   			var errorMessage = '';
	   			if ('' == $(":input[name='name']").val()) { okToSubmit = false; errorMessage+="\nNama harus diisi."; }
	   			
				if(okToSubmit) {
					$("#form").submit();
				} else {
	   				alert("Data-data berikut ini harus diisi dengan benar sebelum disimpan. "+errorMessage);
	   			}
			});
        });
        
    </script>
</head>
<body>
<form id="form" action="<c:url value="save"/>" method="post">
<div align="center">
	<div class="column">
    			<label style="font-size: 1.3em;margin-bottom: 0em;">Crud Example with Spring Hibernate</label>
		</div>
		
	<jsp:include page="message.jsp"></jsp:include>

	<table width="500" style="border-collapse: collapse;" border="0" cellspacing="2" cellpadding="2">                    
        <tr>
            <td width="100" align="right">Id</td>
            <td width="150">
            	<input type="text" name="id" readonly="readonly" value="${simpleCrud.id}"/>
            </td>
        </tr>
        <tr>
            <td width="100" align="right">Nama</td>
            <td>
            	<input type="text" name="name" value="${simpleCrud.name}"/>
            </td>
        </tr>
        <tr>
            <td width="100" align="right">Alamat</td>
            <td>
            	<input type="text" name="address" value="${simpleCrud.address}"/>
            </td>
        </tr>
    </table>  
    <div class="easyui-panel" style="padding: 5px;">
			<a id="btn-save" href="#">Simpan</a> <br />
			<a href="<c:url value="search"/>" href="#">Kembali ke Menu Sebelumnya</a>
	</div>
</div>
</form>
</body>
</html>
